package com.ztgf.shopping.service.shop;

import com.ztgf.shopping.models.dto.shop.ShopCategoryRelationDTO;
import com.ztgf.shopping.models.service.shop.IShopCategoryRelationService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.ztgf.shopping.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ztgf.shopping.mapper.shop.ShopCategoryAuditLogMapper;
import com.ztgf.shopping.models.service.shop.IShopCategoryAuditLogService;
import com.ztgf.shopping.models.bo.shop.ShopCategoryAuditLogSaveBO;
import com.ztgf.shopping.models.dto.shop.ShopCategoryAuditLogDTO;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 店铺品牌分类审核日志控制器
 *
 * @author zhanghualang
 * @Date 2020-06-04 15:07:42
 */
@DubboService
public class ShopCategoryAuditLogServiceImpl extends ServiceImpl<ShopCategoryAuditLogMapper, ShopCategoryAuditLogDTO> implements IShopCategoryAuditLogService{

    @Resource
    private YmlConfig ymlConfig;
    @Autowired
    private IShopCategoryRelationService iShopCategoryRelationService;

    @Override
    public boolean add(ShopCategoryAuditLogSaveBO saveBO) {
        ShopCategoryAuditLogDTO dto = new ShopCategoryAuditLogDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        this.insert(dto);

        //分类表审核信息同步更新
        //日志表审核状态 0打回、1审核通过、2审核失败
        //分类表审核状态 0未审核、1打回、2审核通过、3审核失败
        ShopCategoryRelationDTO shopCategoryRelationDTO = iShopCategoryRelationService.selectById(saveBO.getShopCategoryId());
//        shopCategoryRelationDTO.setAuditStatus(saveBO.getAuditStatus() + 1);
        return iShopCategoryRelationService.updateById(shopCategoryRelationDTO);
    }
}
